package cn.lingyangwl.agile.model.constants;

import cn.lingyangwl.agile.model.module.auth.OAuth2ParamKeys;

/**
 * @author shenguangyang
 */
public interface OAuth2Cons {
    /**
     * 用户登录详细资料
     * arg1: 用户id
     * arg2: 登录id
     * value: 用户数据
     */
    String CACHE_USER_DETAILS = "auth:user_details:%s:%s";

    /**
     * 缓存用户登录记录, 结构为 ZSet, 之所以要进行排序, 是为了比较一些安全隐患导致set集合数据越来越大占用内存,
     * 当排序之后, 每次登录都会取前10个, 进行判断是否过期, 过期就删除
     * arg1: 用户id
     * value: 存放的是用户登录id
     */
    String CACHE_USER_LOGIN_RECORD = "auth:user_login_record:%s";

    /**
     * @deprecated
     * arg1: userId <br/>
     * arg2: token值
     */
    String CACHE_ACCESS_TOKEN = "auth:access_token" + ":%s:%s";

    /**
     * arg1: token type
     * arg2: token值
     * @see OAuth2ParamKeys#ACCESS_TOKEN
     * @see OAuth2ParamKeys#REFRESH_TOKEN
     */
    String CACHE_TOKEN = "auth:token:%s:%s";

    /**
     * 用户权限
     * arg1: 用户id
     * arg2: 租户id
     */
    String CACHE_USER_AUTHORITY = "auth:user_authority:%s:%s";

    interface TokenType {
        String BEARER = "Bearer";
        String BASIC = "Basic";

        String ACCESS_TOKEN = "access";
        String REFRESH_TOKEN = "refresh";
    }
}
